<?php
session_start() ;
if(!isset($_SESSION["login"]) || $_SESSION["login"] == "")
{   
  header("Location: index.php?error=4") ;
}?>

<html>
<head>
<title>Administration</title>
 <link rel="stylesheet" type="text/css" href="style.css" >  
</head>

<body>
<?php require("menu.php");
require("fonctions.php");
$code=$_GET["error"];
?>
<p class="titre">Fiche de synth&egrave;se des d&eacute;cisions RT</p>
<br></br>
<?php 
$id_interv =  $_GET["id_interv"];
 $sql="select * from data_temp where id_interv=$id_interv";
$res = mysql_query($sql);
$r = mysql_fetch_object($res);
?>
<table>
<tr>
	<td class="tab_dis_head" colspan=3>D&eacute;cision en attente de validation RT</td>
</tr>
</table>
<form action="controler.php?action=add_decision_mail" method=post>
<input type="hidden" name="codesap" value="<?php echo $r->code_sap;?>">
<input type="hidden" name="id_interv" value="<?php echo $r->id_interv;?>">

<table class="tab_dis">
<tr>
	<td class="tab_dis_head2">ID_INTERV</td><td class="tab_dis_data"><?php echo $r->id_interv;?></td>
	</tr>
	<tr>
	<td class="tab_dis_head2">CODESAP</td><td class="tab_dis_data"><?php echo $r->code_sap;?></td>
	</tr>
	<tr>
	<td class="tab_dis_head2">ETABLISSEMENT</td><td class="tab_dis_data"><?php echo $r->distributeur;?></td>
	</tr>
	<tr>
	<td class="tab_dis_head2">STATUT</td><td class="tab_dis_data"><?php echo $r->statut;?></td>
	</tr>
	<tr>
	<td class="tab_dis_head2">Envoyer A</td><td class="tab_dis_data"><?php 
	$sql2="(select m.email from distributeurs d
			join asso_dis_man on id_distrib = d.id
			join managers m on id_man = m.id where d.codesap=4205 order by d.codesap)
			
			union 
			
			(select r.email from distributeurs d
			join asso_dis_resp_qual on id_distrib = d.id
			join respon_qual r on id_rq = r.id where d.codesap=4205 order by d.codesap)
			
			union 
			
			(select c.email from distributeurs d
			join contacts c on c.id_distrib=d.id where d.codesap=4205 order by d.codesap
			)";
		$res2=mysql_query($sql2);
		while($r2 = mysql_fetch_object($res2)){
			
			echo $r2->email;echo"&nbsp;&nbsp;";
		}
		$sql3="select * from rt_synth_mail where id_interv=$id_interv";
		if($res3=mysql_query($sql3)){
			$r3 = mysql_fetch_object($res3);
		}
		?>
		<input type="hidden" name="id_synth" value="<?php echo $r3->id;?>">
		
		</td>
	</tr>
	<tr>
	<td class="tab_dis_head2">SUJET</td><td class="tab_dis_data"><input type="text" name="sujet" value="<?php echo $r3->sujet;?>" ></td>
	</tr>
	<tr>
	<td class="tab_dis_head2">MESSAGE</td><td class="tab_dis_data"><textarea cols="75" rows="25" name="message"><?php echo $r3->message;?></textarea></td>
	</tr>
	<tr>
		<td colspan="2" align=center> <input type="submit" value="Envoyer !"></td>
	</tr>


</table>

</form>
</body>

</html>
